
<?

die('<img width=780 src="img/under_construction.png" /> <br /> <center>Under Construction</center>');

function ech($_){echo"<td>".$_."</td>";}

$NUM_PER_PAGE = 30;
$page = (isset($_REQUEST['page']))?$_REQUEST['page']:1;

// Generate Corp / User List
$lookup = array();
$query_all_chars = mysql_query('SELECT * FROM charCharacterSheet',$yap);
while ($data = mysql_fetch_assoc($query_all_chars)) {
	$lookup[$data['characterID']] = $data['name'];
	if (isset($data['corporationID']) && !isset( $lookup[$data['corporationID']] ))
		$lookup[$data['corporationID']] = $data['corporationName'];
	if (isset($data['allianceID']) && !isset( $lookup[$data['allianceID']] ))
		$lookup[$data['allianceID']] = $data['allianceName'];
}
$query_all_corps = mysql_query('SELECT * FROM corpCorporationSheet',$yap);
while ($data = mysql_fetch_assoc($query_all_corps)) {
	if (isset($data['corporationID']) && !isset( $lookup[$data['corporationID']] ))
		$lookup[$data['corporationID']] = $data['corporationName'];
	if (isset($data['allianceID']) && !isset( $lookup[$data['allianceID']] ))
		$lookup[$data['allianceID']] = $data['allianceName'];
}
$query_pos_fuel = mysql_query('SELECT * FROM corpFuel ORDER BY posID ASC',$yap);
while ($data = mysql_fetch_assoc($query_pos_fuel)) {
	$posFuel[$data['posID']][$data['typeID']] = $data['quantity'];
}
	
$query_list_pos = mysql_query('SELECT * FROM corpStarbaseList',$yap);
$total_pos = mysql_num_rows($query_list_pos);
$total_pages = ceil(($total_pos/$NUM_PER_PAGE));

$query_all_pos = mysql_query("SELECT * FROM corpStarbaseList ORDER BY ownerID ASC LIMIT ".(($page*$NUM_PER_PAGE)-$NUM_PER_PAGE).",".$NUM_PER_PAGE,$yap);
while ($data = mysql_fetch_assoc($query_all_pos)) {
	$pos[$data['itemID']] = $data;
}
?>
<table>
<tr>
<td width='150px'><b>Status</b></td>
<td width='150px'><b>Tower Type</b></td>
<td width='150px'><b>Owner</b></td>
<td width='150px'><b>Location</b><br /><b><em>Region</em></b></td>
<td width='150px'><b>Password</b></td>
<td width='150px'><b>Fuel</b><br /><b><em>Stront</em></b></td>
</tr>
<?
	$query = '';
	foreach ($pos as $p) {
		$query .= $p['locationID'].",";
	}
	$query = substr($query,0,-2);

	$status = true;
	$fuel = "0h";
	$password = "unknown";
	
	$query_locations = mysql_query('SELECT * FROM mapDenormalize WHERE itemID IN('.$query.')',$eve);
	while ($data = mysql_fetch_assoc($query_locations)) {
		$loc[$data['itemID']] = $data['itemName'];
	}
	
	foreach ($pos as $data) {
	$stront = (isset($posFuel[$data['itemID']]))?$posFuel[$data['itemID']]['16275']:0;
	echo "<tr>";
		ech($status);
		ech($data['typeID']);
		ech($lookup[$data['ownerID']]);
		ech($loc[$data['locationID']]."<br /><em>".$data['moonID']."</em>");
		ech($password);
		ech($fuel."<br /><em>".$stront."</em>");
	echo "</tr>";
	}
	echo "</table>";
	$bpage = (($page-1)<1)?1:$page-1;
	$npage = (($page+1)>$total_pages)?$total_pages:$page+1;
	echo "<span> <a href=?p=pos&page={$bpage}> Prev</a> Page {$page} of {$total_pages} <a href=?p=pos&page={$npage}>Next</a></span><br />Managed By Yapeal API.";
?>

